package com.letwal.cmcvnd.earn.invite.adapter

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.letwal.cmcvnd.R
import com.letwal.cmcvnd.adata.home.getInviteIncomeList.RevDataGetInviteIncomeList

class InviteDetailAdapter(private val dataList: List<RevDataGetInviteIncomeList>) :
    RecyclerView.Adapter<InviteDetailAdapter.ViewHolder>() {

    inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        var textAdapterInviteDetailDate: TextView =
            view.findViewById(R.id.textAdapterInviteDetailDate)
        var textAdapterInviteDetailEarnAmountValue: TextView =
            view.findViewById(R.id.textAdapterInviteDetailEarnAmountValue)
        var textAdapterInviteDetailInviteAccountNameValue: TextView =
            view.findViewById(R.id.textAdapterInviteDetailInviteAccountNameValue)
        var textAdapterInviteDetailEarnRatioValue: TextView =
            view.findViewById(R.id.textAdapterInviteDetailEarnRatioValue)
    }

    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int,
    ): ViewHolder {
        val view = LayoutInflater.from(parent.context)
            .inflate(R.layout.view_adpter_invite_detail, parent, false)
        return ViewHolder(view)
    }

    @SuppressLint("SetTextI18n")
    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val data: RevDataGetInviteIncomeList = dataList[position]
        holder.textAdapterInviteDetailDate.text = data.time
        holder.textAdapterInviteDetailEarnAmountValue.text = data.income
        holder.textAdapterInviteDetailInviteAccountNameValue.text = data.email
        holder.textAdapterInviteDetailEarnRatioValue.text = data.rate

    }

    override fun getItemCount(): Int {
        return dataList.size
    }
}